/*-------------------------- +
  get
 +-------------------------- */
var get = {
	byId: function(id) {
		return typeof id === "string" ? document.getElementById(id) : id
	},
	byClass: function(tagName, sClass, oParent) {
		var aClass = [];
		var reClass = new RegExp("(^| )" + sClass + "( |$)");
		var aElem = this.byId(oParent).getElementsByTagName(tagName)
		for (var i = 0; i < aElem.length; i++) reClass.test(aElem[i].className) && aClass.push(aElem[i]);
		return aClass
	},
   	nextNode : function(fNode){
		var nNode = fNode.nextSibling;
		while(nNode.nodeType != 1){
			nNode = nNode.nextSibling;
		}
		return nNode;
	},
	lastNode : function(fNode){
		var lNode = fNode.previousSibling;
		while(lNode.nodeType != 1){
			lNode = lNode.previousSibling;
		}
		return lNode;
	}
};
/*-------------------------- +
  addHandler
 +-------------------------- */
var EventUtil = {
    addHandler: function (oElement, sEvent, fnHandler) {
        
        oElement.addEventListener ? oElement.addEventListener(sEvent, fnHandler, false) : (oElement["_" + sEvent + fnHandler] = fnHandler, oElement[sEvent + fnHandler] = function () {oElement["_" + sEvent + fnHandler]()}, oElement.attachEvent("on" + sEvent, oElement[sEvent + fnHandler]))
    },
    removeHandler: function (oElement, sEvent, fnHandler) {
        oElement.removeEventListener ? oElement.removeEventListener(sEvent, fnHandler, false) : oElement.detachEvent("on" + sEvent, oElement[sEvent + fnHandler])
    },
    addLoadHandler: function (fnHandler) {
        this.addHandler(window, "load", fnHandler)
    }
};
/*-------------------------- +
 select
 +-------------------------- */
function SelectBox(obj){
    this.oBox = get.byId(obj);
    this.oInput = this.oBox.getElementsByTagName("input")[0]
    this.oUl = this.oBox.getElementsByTagName("ul")[0]
    this.oLi = this.oUl.getElementsByTagName("li");
    this.form = get.byId('sform');
    var that = this;
    var show = function(){
        that.oUl.style.display = "block";
    };
	var hide = function (){
		that.oUl.style.display = "none";
	}
    var addValue = function(){
        that.oInput.value = this.innerHTML;
        that.form.action=this.id;
		hide();
    }
    EventUtil.addHandler(this.oInput, "click", show);
    for(var i=0, len = this.oLi.length; i < len ;i++){
        EventUtil.addHandler(this.oLi[i], "click", addValue)
    }
};

/*-------------------------- +
  Hover blank
 +-------------------------- */
function fnHover(obj){
	var setting = {};
	var obj = get.byId(obj);
	if(!obj.length){
		hoverLi(obj);
	}else{
		for(var z = 0, l = obj.length; z<l; z++){
			hoverLi(obj[z]);
		}	
	}
	function hoverLi (o) {
		var oLi = o.getElementsByTagName("li");
		var len = oLi.length;
		var counter = 0;
		for(var i=0;i<len;i++){
			oLi[i].onmouseover = function (index) {
				return function () {
					oLi[counter].className = ""
					oLi[index].className = "show";
					counter = index;
				}
			}(i);
		}
	}
}






